A short description of the post.
Importing shapefile using st_read() of sf package. The output object is in tibble sf object class.
Reading layer `MP14_SUBZONE_WEB_PL' from data source
`D:\sarahcsp\IS415_blog\_posts\2021-09-13-in-class-exercise\data\shapefile'
using driver `ESRI Shapefile'
Simple feature collection with 323 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21
Projection is in SVY21.
read_rds() of readr package is used instead of readRDS() of base R is used. This is because output of read_RDS is in tibble object.
Note that there are some data issue in childcare data frame because ‘Lat’ and ‘Lng’ should be in numeric data type.
Note: st_as_sf accept coordinates in character data type.
If you want to change the ‘Lat’ and ‘Lng’ in the original dataset to numeric data type, it is also acceptable.
You can also view more than one data in a single map.
as_Spatial() of sf package.
as.SpatialPoint() of as.SpatialPolygon() of maptools package.
Note that it is no longer a dat frame, it is a formal class. Compare it to childcare and you realise that the data has been dropped from childcare_sp.
Dropping all the projection information. All that would be left is the coordinates.
[1] FALSE